/**
 * @title AttentionMatchFragment.java
 * @package com.esun.cheetah.view.match.matchlist.fragments
 * @description 关注比赛列表界面
 * @author liugan
 * @date 2012-7-23
 * @copyright 深圳市易讯天空
 */
package com.esun.cheetah.view.match.matchlist.fragments;

import com.esun.cheetah.biz.match.matchlist.MatchListManager;
import com.esun.cheetah.view.match.matchlist.adapter.OneDayMatchAdapter;
import com.esun.cheetah.view.match.matchlist.adapter.SeparatedMatchListAdapter;

import android.os.Bundle;

/**
 * @title AttentionMatchFragment
 * @description 关注比赛列表界面
 * @author liugan
 */
public class AttentionMatchFragment extends AbsListFragment{
	
	/**
     * Create a new instance of CountingFragment, providing "num"
     * as an argument.
     */
    public  static AttentionMatchFragment newInstance(int num) {
    	AttentionMatchFragment f = new AttentionMatchFragment();

        // Supply num input as an argument.
        Bundle args = new Bundle();
        args.putInt("num", num);
        f.setArguments(args);

        return f;
    }

	@Override
	protected SeparatedMatchListAdapter createListAdapter() {
		SeparatedMatchListAdapter adapter = new SeparatedMatchListAdapter(getActivity());	
		return adapter;
	}

	@Override
	public boolean isNeedUpdate() {
		return MatchListManager.getInstance().isAttentionedNeedUpdate();
	}

	@Override
	public void update() {
		super.setUpdateTime(MatchListManager.getInstance().getUpdateTime());
		SeparatedMatchListAdapter adapter = getListAdapter();
		adapter.clear();
		
		if(MatchListManager.getInstance().getAttentionedMatches().size() != 0){
			OneDayMatchAdapter oneDayMatchAdapter = new OneDayMatchAdapter(getActivity());
			oneDayMatchAdapter.setList(MatchListManager.getInstance().getAttentionedMatches());
			adapter.addSection("2012-08-03", oneDayMatchAdapter);
			hideEmptyText();
		}else{
			showEmptyText();
		}
		
		adapter.notifyDataSetChanged();
		MatchListManager.getInstance().setAttentionedNeedUpdate(false);
	}

}
